package com.ytjj.qmyx.admin.controller.data;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.response.ProductDataResponse;
import com.ytjj.qmyx.admin.model.response.statistics.RedPacketResponse;
import com.ytjj.qmyx.admin.service.data.ProductStatisticsService;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 商品统计
 * @ClassName ProductStatisticsController
 *
 *
 * @Version 1.0
 **/


@RestController
@RequestMapping("/productStatistics")
public class ProductStatisticsController {

    @Resource
    private ProductStatisticsService productStatisticsService;

    /**
     * 商品表格统计部分
     * @return
     */
    @GetMapping("/getProductStatisticList")
    public CommonResult getProductStatisticList(@RequestParam("dateType") String dateType,
                                                @RequestParam("platform") String platform,
                                                @RequestParam("channel") String channel) {
        return CommonResult.success(productStatisticsService.getProductStatisticList(dateType, platform, channel));
    }

    /**
     * 商品数据统计
     */
    @GetMapping("/getTodayProductData")
    public CommonResult<List<ProductDataResponse>> getTodayProductData(@RequestParam("platform") String platform,
                                                                       @RequestParam("channel") String channel) {
        return CommonResult.success(productStatisticsService.getTodayProductData(platform, channel));
    }


    /**
     * 商品数据统计(根据时间筛选)
     */
    @GetMapping("/getProductDataByDay")
    public CommonResult<List<ProductDataResponse>> getProductDataByDay(@RequestParam("platform") String platform,
                                                                       @RequestParam("channel") String channel,
                                                                       @RequestParam("dateTime") String dateTime) {
        return CommonResult.success(productStatisticsService.getProductDataByDay(platform, channel, dateTime));
    }

    /**
     * 商品数据统计(根据具体时间筛选)
     */
    @GetMapping("/queryProductDataByDay")
    public CommonResult queryProductDataByDay(@RequestParam("platform") String platform,
                                                                       @RequestParam("channel") String channel,
                                                                           @RequestParam("dayTime") String dayTime) {
        return CommonResult.success(productStatisticsService.queryProductDataByDay(platform, channel, dayTime));
    }

    /**
     * 红包相关数据统计
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/findRedPacketList")
    public CommonResult findRedPacketList(String startDate,String endDate){
        Assert.notNull(startDate, "开始日期不能为空");
        Assert.notNull(startDate, "结束日期不能为空");
        List<RedPacketResponse> data= productStatisticsService.findRedPacketList(startDate, endDate);
        return CommonResult.success(data);
    }


}
